package 不相邻取数;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] f = new int[n + 1];
        int[] g = new int[n + 1];
        int[] a = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            a[i] = in.nextInt();
        }
        for (int i = 1; i <= n; i++) {
            f[i] = g[i - 1] + a[i];
            g[i] = Math.max(f[i - 1], g[i - 1]);
        }
        System.out.println(Math.max(f[n], g[n]));
    }
}
